﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ERP.Workflow.Designer.EntityFrameworkCore.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "WdDefinition",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Version = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WdDefinition", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "WdNode",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Title = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    X = table.Column<double>(type: "double", nullable: false),
                    Y = table.Column<double>(type: "double", nullable: false),
                    Width = table.Column<double>(type: "double", nullable: false),
                    Height = table.Column<double>(type: "double", nullable: false),
                    DefinitionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WdNode", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WdNode_WdDefinition_DefinitionId",
                        column: x => x.DefinitionId,
                        principalTable: "WdDefinition",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "WdPort",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ParentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    X = table.Column<double>(type: "double", nullable: false),
                    Y = table.Column<double>(type: "double", nullable: false),
                    Width = table.Column<double>(type: "double", nullable: false),
                    Height = table.Column<double>(type: "double", nullable: false),
                    DefinitionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    PortAlignments = table.Column<int>(type: "int", nullable: false),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WdPort", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WdPort_WdDefinition_DefinitionId",
                        column: x => x.DefinitionId,
                        principalTable: "WdDefinition",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_WdPort_WdNode_ParentId",
                        column: x => x.ParentId,
                        principalTable: "WdNode",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "WdLink",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Content = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Selected = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Color = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SelectedColor = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Width = table.Column<double>(type: "double", nullable: false),
                    Paths = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SourceNodeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    TargetNodeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    SourcePortId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    TargetPortId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    SourceLinkMarkerPath = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SourceLinkMarkerWidth = table.Column<double>(type: "double", nullable: false),
                    TargetLinkMarkerPath = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TargetLinkMarkerWidth = table.Column<double>(type: "double", nullable: false),
                    DefinitionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WdLink", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WdLink_WdDefinition_DefinitionId",
                        column: x => x.DefinitionId,
                        principalTable: "WdDefinition",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_WdLink_WdNode_SourceNodeId",
                        column: x => x.SourceNodeId,
                        principalTable: "WdNode",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_WdLink_WdNode_TargetNodeId",
                        column: x => x.TargetNodeId,
                        principalTable: "WdNode",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_WdLink_WdPort_SourcePortId",
                        column: x => x.SourcePortId,
                        principalTable: "WdPort",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_WdLink_WdPort_TargetPortId",
                        column: x => x.TargetPortId,
                        principalTable: "WdPort",
                        principalColumn: "Id");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "WdLinkLabel",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Content = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Distance = table.Column<double>(type: "double", nullable: true),
                    OffsetX = table.Column<double>(type: "double", nullable: false),
                    OffsetY = table.Column<double>(type: "double", nullable: false),
                    DefinitionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WdLinkLabel", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WdLinkLabel_WdDefinition_DefinitionId",
                        column: x => x.DefinitionId,
                        principalTable: "WdDefinition",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_WdLinkLabel_WdLink_ParentId",
                        column: x => x.ParentId,
                        principalTable: "WdLink",
                        principalColumn: "Id");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "WdLinkVertex",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    X = table.Column<double>(type: "double", nullable: true),
                    Y = table.Column<double>(type: "double", nullable: true),
                    DefinitionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WdLinkVertex", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WdLinkVertex_WdDefinition_DefinitionId",
                        column: x => x.DefinitionId,
                        principalTable: "WdDefinition",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_WdLinkVertex_WdLink_ParentId",
                        column: x => x.ParentId,
                        principalTable: "WdLink",
                        principalColumn: "Id");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_WdLink_DefinitionId",
                table: "WdLink",
                column: "DefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLink_SourceNodeId",
                table: "WdLink",
                column: "SourceNodeId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLink_SourcePortId",
                table: "WdLink",
                column: "SourcePortId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLink_TargetNodeId",
                table: "WdLink",
                column: "TargetNodeId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLink_TargetPortId",
                table: "WdLink",
                column: "TargetPortId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLinkLabel_DefinitionId",
                table: "WdLinkLabel",
                column: "DefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLinkLabel_ParentId",
                table: "WdLinkLabel",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLinkVertex_DefinitionId",
                table: "WdLinkVertex",
                column: "DefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_WdLinkVertex_ParentId",
                table: "WdLinkVertex",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_WdNode_DefinitionId",
                table: "WdNode",
                column: "DefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_WdPort_DefinitionId",
                table: "WdPort",
                column: "DefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_WdPort_ParentId",
                table: "WdPort",
                column: "ParentId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "WdLinkLabel");

            migrationBuilder.DropTable(
                name: "WdLinkVertex");

            migrationBuilder.DropTable(
                name: "WdLink");

            migrationBuilder.DropTable(
                name: "WdPort");

            migrationBuilder.DropTable(
                name: "WdNode");

            migrationBuilder.DropTable(
                name: "WdDefinition");
        }
    }
}
